{include file="common/_header-css"}
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="account" class="layui-form-label">
                    <span class="x-red">*</span>员工号</label>
                <div class="layui-input-inline">
                    <input type="text" id="account" name="account" required="" lay-verify="account" autocomplete="off" placeholder="请填写员工号" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>将会成为您唯一的登入名</div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>名字</label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="username" required="" lay-verify="nikename" autocomplete="off" placeholder="请填写员工名字" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="password" class="layui-form-label">
                    <span class="x-red">*</span>密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="password" name="password" required="" lay-verify="pass" placeholder="请填写员工密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>性别</label>
                <div class="layui-input-inline">
                    <select name="sex">
                        <option value="1">男</option>
                        <option value="">女</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>选择部门</label>
                <div class="layui-input-inline">
                    <select name="department_id">
                        {volist name="list" id='vo'}
                        <option value="{$vo.id}" data-name="{$vo.department}">{$vo.department}</option>
                        {volist name='$vo.tree' id='tree_vo'}
                        <option value="{$tree_vo.id}" data-name="{$tree_vo.department}">&nbsp;&nbsp;| --&nbsp;{$tree_vo.department}</option>
                        {volist name='$tree_vo.tree' id='tree_one_vo'}
                        <option value="{$tree_one_vo.id}" data-name="{$tree_one_vo.department}">&nbsp;&nbsp;| --&nbsp;&nbsp;| --&nbsp;{$tree_one_vo.department}</option>
                        {/volist}
                        {/volist}
                        {/volist}
                    </select>
                </div>
                <input type="hidden" id="department_name" name="department_name" value="">
            </div>

            <div class="layui-form-item">
                <label for="level_id" class="layui-form-label">
                    <span class="x-red">*</span>选择等级</label>
                <div class="layui-input-inline">
                    <select id="level_id" name="level_id">
                        {volist name="level" id='vo'}
                        <option value="{$vo.id}">{$vo.level_name}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer','jquery'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(add)',
            function(data) {

                if (data.field.account == "") {
                    layer.msg('账号不能为空!',{icon:5,time:800});
                    return false;
                }
                if (data.field.username == "") {
                    layer.msg('用户名字不能为空!',{icon:5,time:800});
                    return false;
                }
                if (data.field.password == "") {
                    layer.msg('用户密码不能为空!',{icon:5,time:800});
                    return false;
                }
                data.field['department_name'] = $('select[name=\'department_id\'] option:selected').attr('data-name');
                $.post('{:url(\'member/member_add\')}',data.field,function (res) {
                    if (res.code == 200) {
                        layer.alert(res.msg, {icon: 6}, function() {
                            xadmin.father_reload();
                        });
                    }else{
                        layer.msg(res.msg,{icon:5,time:500});
                    }

                });

                return false;
            });

    });
</script>
</body>

</html>